<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改资产领用')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-receive-edit"  th:object="${assetsReceive}">
            <h4 class="form-header h4">资产领用信息</h4>
            <input name="receiveId" th:field="*{receiveId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">资产编号：</label>
                <div class="col-sm-8">
                    <input name="assetsId" th:field="*{assetsId}" readonly="readonly" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">领用人编号：</label>
                <div class="col-sm-8">
                    <input name="userId" th:field="*{userId}" readonly="readonly" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">领用人：</label>
                <div class="col-sm-8">
                    <input name="userName" th:field="*{userName}" readonly="readonly" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">SN号：</label>
                <div class="col-sm-8">
                    <input name="assetsSn" th:field="*{assetsSn}" readonly="readonly" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">资产名称：</label>
                <div class="col-sm-8">
                    <input name="assetsName" th:field="*{assetsName}" readonly="readonly" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">领用日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="receiveTime" readonly="readonly" th:value="${#dates.format(assetsReceive.receiveTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">

                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">领用编号：</label>
                <div class="col-sm-8">
                    <input name="receiveNo" readonly="readonly" th:field="*{receiveNo}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <select name="receiveType" disabled="disabled" class="form-control m-b" th:with="type=${@dict.getType('receive_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{receiveType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="receiveDesc" readonly="readonly" th:field="*{receiveDesc}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">附件：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="receiveFile" th:field="*{receiveFile}">
                    <div class="file-loading">
                        <input class="form-control file-upload" readonly="readonly" id="receiveFile" name="file" type="file">
                    </div>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "assets/receive";
        var assetsTypeDatas = [[${@dict.getType('assets_type')}]];
        var assetsAreaDatas = [[${@dict.getType('area_type')}]];
        var assetsCompanyDatas = [[${@dict.getType('company')}]];
        var assetsStatusDatas = [[${@dict.getType('assets_status')}]];
        $("#form-receive-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-receive-edit').serialize());
            }
        }

        $("input[name='receiveTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });

    </script>
</body>
</html>